home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / snmp / mib2c-data / node-varbind-validate.m2i < prev    next >
Encoding:
Text File  |  2007-02-07  |  3.9 KB  |  109 lines

  1. #############################################################  -*- c -*-
  2. ## generic include for XXX. Do not use directly.
  3. ##
  4. ## $Id: node-varbind-validate.m2i,v 1.4 2004/09/09 23:15:38 rstory Exp $
  5. ##
  6. ## Tests a netsnmp_variable_list pointer (var) against known
  7. ## contstraints. If none are found, calls the user supplied funtion
  8. ## ${node}_check_value.
  9. ##
  10. ## Sets the variable rc to a SNMP_ERR.
  11. ##
  12. ## Requirements
  13. ## ------------
  14. ## $m2c_nvv_sizeof: variable name appropriate for a sizeof() call to
  15. ##                  check variable length. If NULL, no size check
  16. ##                  will be done.
  17. ##
  18. ########################################################################
  19. @if $m2c_mark_boundary == 1@
  20. /** START code generated by $RCSfile: node-varbind-validate.m2i,v $ $Revision: 1.4 $ */
  21. @end@
  22. ########################################################################
  23. ##----------------------------------------------------------------------
  24. ## setup
  25. ##----------------------------------------------------------------------
  26. @if $m2c_paranoid == 1@
  27. netsnmp_assert(rc == SNMP_ERR_NOERROR); /* paranoia */
  28. @end@
  29. ##----------------------------------------------------------------------
  30. ## syntax specific
  31. ##----------------------------------------------------------------------
  32. @ifconf syntax-$node.syntax-varbind-validate.m2i@
  33. @   include syntax-$node.syntax-varbind-validate.m2i@
  34. @else@
  35. ##----------------------------------------------------------------------
  36. ## Check type
  37. ##----------------------------------------------------------------------
  38. ## if not generated code or is OCTET_STR, length checks are up to user
  39. @   if ($m2c_node_needlength == 1) || ("x$m2c_nvv_sizeof" eq "x")@
  40.     rc = netsnmp_check_vb_type( var, $node.type );
  41. @   else@
  42.     rc = netsnmp_check_vb_type_and_size( var, $node.type,
  43.         sizeof( $m2c_nvv_sizeof ) );
  44. @   end@
  45. ##----------------------------------------------------------------------
  46. ## check ENUMS
  47. ##----------------------------------------------------------------------
  48. @   if $node.enums == 1@
  49.     if(SNMPERR_SUCCESS == rc) {
  50.  
  51. ##------------------------------------------------------
  52. @      if "$node.perltype" ne "BITS"@
  53.     /* check that the value is one of defined enums */
  54.     if( 1
  55. @         foreach $e $v enum@
  56. @            include m2c_setup_enum.m2i@
  57.  && ( *var->val.integer != $m2c_ename )
  58. @         end@ # for each
  59.         ) {
  60.         rc = SNMP_ERR_WRONGVALUE;
  61.         }
  62. ##------------------------------------------------------
  63. @      else@ # BITS
  64. ## {
  65.     if(var->val_len > 4) {
  66.         snmp_log(LOG_ERR,"I can not handle BITS > 4 bytes\n");
  67.         rc = SNMP_ERR_GENERR;
  68.     }
  69.     else {
  70.         u_long bits = 0;
  71.         /* check that value is within enum mask */
  72.         memcpy( &bits, var->val.string, var->val_len);
  73.         if( (bits | $m2c_enum_mask) != $m2c_enum_mask)
  74.         rc = SNMP_ERR_WRONGVALUE;
  75.     }
  76. @      end@
  77.     }
  78. ##----------------------------------------------------------------------
  79. ## check RANGES
  80. ##----------------------------------------------------------------------
  81. @   elsif $node.ranges == 1@
  82. @      if ("$node.decl" eq "long") || ("$node.decl" eq "u_long")@
  83. @         eval $m2c_nvv_func = "netsnmp_check_vb_int_range"@
  84. ##@         eval $m2c_nvv_rc = "SNMP_ERR_WRONGVALUE"@
  85. @      else@
  86. @         eval $m2c_nvv_func = "netsnmp_check_vb_size_range"@
  87. ##@         eval $m2c_nvv_rc = "SNMP_ERR_WRONGLENGTH"@
  88. @      end@
  89.     if(SNMPERR_SUCCESS == rc) {
  90.     /* check that the value is in the defined range(s); inefficent
  91.      * but keeps rc value knowledge in libarary where it belongs. */
  92.     if( 1
  93. @    foreach $a $b range $node@
  94.        && ((rc = $m2c_nvv_func(var, $a,$b)) != SNMP_ERR_NOERROR)
  95. @    end@
  96.      ) {
  97.         ; /* rc set in condition */
  98.     }
  99.    }
  100. @   else@
  101.     /* yyy-rks: anything else we can do here? */
  102. @   end@
  103. @end@ # not syntax specific
  104. ##
  105. ########################################################################
  106. @if $m2c_mark_boundary == 1@
  107. /** END code generated by $RCSfile: node-varbind-validate.m2i,v $ $Revision: 1.4 $ */
  108. @end@
  109.